<?php
class ListaBlancaModel extends Zwei_Db_TableLoggeable
{
    protected $_name = "lista_blanca";

    public function select()
    {
    	$this->setAdapter("dn");
        $select = new Zend_Db_Table_Select($this);	
        $select->from($this->_name, array(
            "id_promo",
            "inicio_inscripcion" => new Zend_Db_Expr("DATE_FORMAT(inicio_inscripcion, '%d-%m-%Y')"),
            "fin_inscripcion" => new Zend_Db_Expr("DATE_FORMAT(inicio_consumo, '%d-%m-%Y')"),
            "fin_consumo" => new Zend_Db_Expr("DATE_FORMAT(fin_consumo, '%d-%m-%Y')"),
            "total" => "numero_clientes"
        ));
        
    	return $select;
    }
    
    /**
     * 
     * @param $id_promo string
     * @param $ini_inscripcion string
     * @return Zend_Db_Table_Select
     */
    public function selectIdLista($id_promo, $ini_inscripcion)
    {
    	$this->setAdapter("dn");
    	$select = new Zend_Db_Table_Select($this); 
    	$select->from($this->_name ,array('id_lista'))
           ->where($this->getAdapter()->quoteInto('id_promo = ?', $id_promo))
           ->where($this->getAdapter()->quoteInto('inicio_inscripcion = ?', $ini_inscripcion));
           
           
           Debug::writeBySettings($select->__toString(), "query_log");
        return $select;         
    }
    
    public function insert($data)
    {
        $this->setAdapter("an");
        return parent::insert($data);
    }
    
    public function update($data, $where)
    {
        $this->setAdapter("an");
        return parent::update($data, $where);
    }
    
    public function delete($where)
    {
        $this->setAdapter("an");
        return parent::delete($where);
    }   
	
}
